<?= $this->Html->script('admin-product') ?>

<h1>
    Proizvodi
    <span class="actions">
        <?= $this->Html->link('dodaj', 'javascript:void(0)', array(
            'onclick' => "addGroup()",
            'title'   => 'Dodaj grupu',
            'class'   => 'add',
            'id'      => 'add-group-btn'
        )) ?>
        <span id="add-group" style="display:none">
            <input type="text">
            <a href="javascript:void(0)" class="action save" title="Sačuvaj">save</a>
            <a href="javascript:void(0)" class="action cancel" title="Poništi">cancel</a>
        </span>
    </span>
</h1>
<div class="accordion" id="product-accordion">
    
    <? foreach ($groups as $id=>$name): ?>
    <h2 class="group-<?= $id ?>" data-id="<?= $id ?>" data-name="<?= $name ?>">
        <span class="label"><?= $name ?></span>
        <span class="actions">
            <?= $this->Html->link('dodaj', 'javascript:void(0)', array(
                'onclick' => "addProduct({$id})",
                'title'   => 'Dodaj proizvod',
                'class'   => 'add'
            )) ?>
            <?= $this->Html->link('izmeni', 'javascript:void(0)', array(
                'onclick' => "editGroup({$id}, '{$name}')",
                'title'   => 'Izmeni grupu',
                'class'   => 'edit'
            )) ?>
            <?= $this->Html->link('obriši', 'javascript:void(0)', array(
                'onclick' => "remoteDelete('/admin_proizvodi/delete_group/{$id}', {$id}, groupDeleted)",
                'class'   => 'delete',
                'title'   => 'Obriši grupu'
            )) ?>
        </span>
    </h2>
    <div class="group-<?= $id ?>">
    </div>
    <? endforeach ?>
</div>